﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Common;
using DataAccess;
using Entity;
using System.Data;

namespace Business
{
    /// <summary>
    /// Summary description for CommentBusiness
    /// </summary>
    public class CommentBusiness : AbstractBusiness
    {
        private CommentDAL _commentDal;
        public CommentBusiness()
        {
            _commentDal = new CommentDAL();
        }

        public PaginatedInfo<Comment> GetAllCommentByArticle(Guid articleId, int pageIndex, int pageSize)
        {
            return _commentDal.GetCommentByArticle(articleId, pageIndex, pageSize);
        }

        public bool Add(Guid article, string postedPerson, string message)
        {
            Comment comment = new Comment();
            comment.Id = Guid.NewGuid();
            comment.Article = article;
            comment.PostedPerson = postedPerson;
            comment.Message = message;
            comment.PostedDate = DateTime.Now;
            return _commentDal.Add(comment);
        }

        public bool Delete(Guid id)
        {
            return _commentDal.Delete(id);
        }
    }
}